//
//  InviteViewController.m
//  ZhumuSDKSample
//
//  Copyright 2006-2015 SUIRUI Co., Ltd. All rights reserved.
//

#import "InviteViewController.h"

@interface InviteViewController ()

@property (retain, nonatomic) UILabel *meetingURLLabel;

@end

@implementation InviteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];
    
    UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(onCancel:)];
    [self.navigationItem setLeftBarButtonItem:cancelItem];
    
    UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(onCancel:)];
    [self.navigationItem setRightBarButtonItem:doneItem];
    
    NSString *meetingID = [ZhumuSDKInviteHelper sharedInstance].meetingID;
    self.title = meetingID;
    
    [self.view addSubview:self.meetingURLLabel];
    NSString *meetingURL = [ZhumuSDKInviteHelper sharedInstance].joinMeetingURL;
    self.meetingURLLabel.text = meetingURL;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UILabel*)meetingURLLabel
{
    if (!_meetingURLLabel)
    {
        _meetingURLLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _meetingURLLabel.numberOfLines = 0;
        _meetingURLLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    return _meetingURLLabel;
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
    self.meetingURLLabel.frame = self.view.bounds;
}

- (void)onCancel:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:NULL];
}

@end
